package cn.itcast.web.controller.system;

import cn.itcast.service.system.LogService;
import cn.itcast.web.controller.BaseController;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
//日志
@Controller
@RequestMapping("/system/log")
public class LogController extends BaseController {
    @Autowired
    private LogService logService;
    /**
     * 分页查询日志
     * 1）方法的访问路径http://localhost:8080/system/log/list.do
     * 2）方法的参数
     * 3）方法的返回内容： "/system/log/log-list"
     */
    @RequestMapping("/list")
    public String list(@RequestParam(defaultValue = "1") int pageNum,
                       @RequestParam(defaultValue = "5") int pageSize) {
        //获取企业id
        String companyId =getLoginCompanyId() ;
        //1.调用业务获取数据
        PageInfo pageInfo = logService.findByCompanyId(pageNum, pageSize, companyId);

        //2.存入request域中，提供给页面显示
        request.setAttribute("pageInfo", pageInfo);

        return "/system/log/log-list";
    }

}
